package uiLayer;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import javax.swing.BoxLayout;

import controlLayer.OrderCtr;

import java.awt.Dimension;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class MainFrame extends JFrame {

	private JPanel contentPane;
	private JPanel mainPanel = new JPanel();
	//private SaleTabbedPanel saleTabbedPanel = new SaleTabbedPanel();
	private SaleTabbedPane saleTabbedPane = new SaleTabbedPane();
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MainFrame frame = new MainFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public MainFrame() {
		setTitle("WesternStyle Salgssystem");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 800, 600);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		contentPane.add(mainPanel, BorderLayout.CENTER);
		mainPanel.setLayout(new BorderLayout(0, 0));
		
		JPanel leftPanel = new JPanel();
		contentPane.add(leftPanel, BorderLayout.WEST);
		leftPanel.setLayout(new BorderLayout(0, 0));
		
		JPanel menuPanel = new JPanel();
		leftPanel.add(menuPanel, BorderLayout.NORTH);
		menuPanel.setLayout(new BoxLayout(menuPanel, BoxLayout.Y_AXIS));
		
		JPanel buttonPanel1 = new JPanel();
		buttonPanel1.setBorder(new EmptyBorder(10, 5, 5, 5));
		menuPanel.add(buttonPanel1);
		buttonPanel1.setLayout(new BoxLayout(buttonPanel1, BoxLayout.X_AXIS));
		
		
		JToggleButton btnKunde = new JToggleButton("Kunde");
		btnKunde.setPreferredSize(new Dimension(90, 40));
		btnKunde.setMinimumSize(new Dimension(90, 40));
		btnKunde.setMaximumSize(new Dimension(90, 40));
		buttonPanel1.add(btnKunde);
		
		JPanel buttonPanel2 = new JPanel();
		buttonPanel2.setBorder(new EmptyBorder(5, 5, 5, 5));
		menuPanel.add(buttonPanel2);
		buttonPanel2.setLayout(new BoxLayout(buttonPanel2, BoxLayout.X_AXIS));
		
		JToggleButton btnProdukt = new JToggleButton("Produkt");
		btnProdukt.setMinimumSize(new Dimension(90, 40));
		btnProdukt.setMaximumSize(new Dimension(90, 40));
		btnProdukt.setPreferredSize(new Dimension(90, 40));
		buttonPanel2.add(btnProdukt);
		
		JPanel buttonPanel3 = new JPanel();
		buttonPanel3.setBorder(new EmptyBorder(5, 5, 5, 5));
		menuPanel.add(buttonPanel3);
		buttonPanel3.setLayout(new BoxLayout(buttonPanel3, BoxLayout.X_AXIS));
		
		JToggleButton btnSalg = new JToggleButton("Salg");
		btnSalg.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				doHandleClicked();
			}
		});
		btnSalg.setPreferredSize(new Dimension(90, 40));
		btnSalg.setMinimumSize(new Dimension(95, 40));
		btnSalg.setMaximumSize(new Dimension(95, 40));
		buttonPanel3.add(btnSalg);
		
		
	}

	protected void doHandleClicked() {
		mainPanel.add(saleTabbedPane, BorderLayout.CENTER);
		revalidate();
	}
	
	/**
	 * @return the saleTabbedPane
	 */
	protected SaleTabbedPane getSaleTabbedPane() {
		return saleTabbedPane;
	}

	/**
	 * @param saleTabbedPane the saleTabbedPane to set
	 */
	public void setSaleTabbedPane(SaleTabbedPane saleTabbedPane) {
		this.saleTabbedPane = saleTabbedPane;
	}


}
